package com.itheima.web;

import com.itheima.Service.UserService;
import com.itheima.dao.pojo.User;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/queryUserByIDServlet")
public class QueryUserByIDServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取请求中的id值
        Integer id =Integer.parseInt(request.getParameter("id")) ;
        //调用方法根据id获取用户的信息
        UserService userService = new UserService();
        User user = userService.getUserById(id);
        //将suer对象转发
        request.setAttribute("user" , user);
        request.getRequestDispatcher("/update.jsp").forward(request,response);


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
